<template>
	<!-- 设施信息 -->
	<view class="facility-container">
		<view class="title">
			<view class="left">设施信息</view>
			<view class="right">
				<text class="add" @click="onAdd">
					+
				</text>
				<text @click="onAdd" style="color: #5094FF;">新增设施</text>
				<text v-if="isShowMore" class="more" @click="goMore">查看更多</text>
			</view>
		</view>
		<view class="info">
			<view v-if="hydrantList.length !== 0">
				<view class="info-title">消防栓：{{hydrantLength}}个</view>
				<view class="info-item" @click="onEdit(item.id)" v-for="item in hydrantList" :key="item.id" >
					<view>
						<view class="info-wrap">设施编号：{{item['设施编号']}}</view>
						<view class="info-wrap">设施名称：{{item['设施名称']}}</view>
						<view class="info-wrap">具体位置：{{item['具体位置']}}</view>
					</view>
					<view class="arrow"></view>
					<view class="delete" @click.stop="onDelete(item.id)">删除</view>
				</view> 
			</view>
			<!-- <view v-else class="empty">暂无设施</view> -->
			<view v-if="annihilatorList.length !== 0">
				<view class="info-title">灭火器：{{annihilatorLength}}个</view>
				<view class="info-item" @click="onEdit(item.id)" v-for="item in annihilatorList" :key="item.id" >
					<view>
						<view class="info-wrap">设施编号：{{item['设施编号']}}</view>
						<view class="info-wrap">设施名称：{{item['设施名称']}}</view>
						<view class="info-wrap">具体位置：{{item['具体位置']}}</view>
					</view>
					<view class="arrow"></view>
					<view class="delete" @click.stop="onDelete(item.id)">删除</view>
				</view> 
			</view>
			<!-- <view v-else class="empty">暂无设施</view> -->
			<view v-if="smokeList.length !== 0">
				<view class="info-title">烟雾探测器：{{smokeLength}}个</view>
				<view class="info-item" @click="onEdit(item.id)" v-for="item in smokeList" :key="item.id" >
					<view>
						<view class="info-wrap">设施编号：{{item['设施编号']}}</view>
						<view class="info-wrap">设施名称：{{item['设施名称']}}</view>
						<view class="info-wrap">具体位置：{{item['具体位置']}}</view>
					</view>
					<view class="arrow"></view>
					<view class="delete" @click.stop="onDelete(item.id)">删除</view>
				</view> 
			</view>
			<!-- <view v-else class="empty">暂无设施</view> -->
			<view v-if="temperateList.length !== 0">
				<view class="info-title">温度探测器：{{temperatelength}}个</view>
				<view class="info-item" @click="onEdit(item.id)" v-for="item in temperateList" :key="item.id" >
					<view>
						<view class="info-wrap">设施编号：{{item['设施编号']}}</view>
						<view class="info-wrap">设施名称：{{item['设施名称']}}</view>
						<view class="info-wrap">具体位置：{{item['具体位置']}}</view>
					</view>
					<view class="arrow"></view>
					<view class="delete" @click.stop="onDelete(item.id)">删除</view>
				</view> 
			</view>
			<!-- <view v-else class="empty">暂无设施</view> -->
			<view v-if="gasTankList.length !== 0">
				<view class="info-title">煤气罐：{{gasTankLength}}个</view>
				<view class="info-item" @click="onEdit(item.id)" v-for="item in gasTankList" :key="item.id" >
					<view>
						<view class="info-wrap">设施编号：{{item['设施编号']}}</view>
						<view class="info-wrap">设施名称：{{item['设施名称']}}</view>
						<view class="info-wrap">具体位置：{{item['具体位置']}}</view>
					</view>
					<view class="arrow"></view>
					<view class="delete" @click.stop="onDelete(item.id)">删除</view>
				</view> 
			</view>
			<view v-if="isEmpty" class="empty">暂无设施</view>
		</view>
	</view>
</template>

<script>
	export default {
		// props: ['install-List'],
		props: {
			hydrantLength: {
				type: Number
			},
			annihilatorLength: {
				type: Number
			},
			smokeLength: {
				type: Number
			},
			temperatelength: {
				type: Number
			},
			gasTankLength: {
				type: Number
			},
			hydrantList: {
				required: true
			},
			annihilatorList: {
				required: true
			},
			smokeList: {
				required: true
			},
			temperateList: {
				required: true
			},
			gasTankList: {
				required: true
			},
			// installList: {
			// 	required: true
			// },
			isShowMore: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				facilityType: this.$type.facilityType
			}
		},
		computed: {
			isEmpty() {
				return this.hydrantLength == 0 && this.smokeLength == 0 && this.annihilatorLength == 0 && this.temperatelength == 0 && this.gasTankLength == 0
			}
		},
		methods: {
			onAdd() {
				this.$emit('add')
			},
			onDelete(id) {
				this.$emit('delete', id)
			},
			onEdit(id) {
				this.$emit('edit', id)
			},
			goMore() {
				this.$emit('more')
			}
		}
	}
</script>

<style lang="scss" scoped>
.title {
	padding: 0 14rpx;
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 40rpx;
	font-size: 34rpx;
	.left {
		font-size: 32rpx;
		&:before {
			content: '';
			position: absolute;
			top: 24rpx;
			left: 24rpx;
			width: 6rpx;
			height: 34rpx;
			background-color: #5094FF;
		}
	}
	.right {
		// display: flex;
		.more {
			position: relative;
			font-size: 34rpx;
			color: #5094FF;
			margin-left: 20rpx;
			&:after {
				content: '';
				position: absolute;
				top: 14rpx;
				right: -16rpx;
				width: 16rpx;
				height: 16rpx;
				border-top: 2rpx solid #5094FF;
				border-right: 2rpx solid #5094FF;
				transform: rotate(45deg);
			}
		}
	}
	.add {
		font-size: 32rpx;
		font-weight: bold;
		color: #5094FF;
		margin-right: 10rpx;
	}
}
.info {
	margin-left: 16rpx;
	// display: flex;
	// justify-content: center;
	// align-items: center;
	.empty {
		// width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		height: 174rpx;
		color: #999;
	}
	.info-title {
		margin-bottom: 20rpx;
	}
	.info-item {
		position: relative;
		box-shadow: 0px 1px 6rpx 0px #EEEEEE;
		border-radius: 8rpx;
		margin-bottom: 10rpx;
		font-size: 32rpx;
		
		.info-wrap {
			line-height: 50rpx;
			font-size: 28rpx;
			width: 20em;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}
		.arrow {
			position: absolute;
			top: 60rpx;
			right: 40rpx;
			width: 20rpx;
			height: 20rpx;
			border-top: 2rpx solid #333;
			border-right: 2rpx solid #333;
			transform: rotate(45deg);
		}
		.delete {
			position: absolute;
			right: 20rpx;
			bottom: 10rpx;
			text-align: center;
			line-height: 35rpx;
			width: 70rpx;
			height: 35rpx;
			font-size: 22rpx;
			color: #E57544;
			border: 2rpx solid #E57544;
		}
	}
}
</style>
